#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
#
# pmempool_sync_remote/TEST21 -- pmempool sync with remote replication
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type any

require_sds $PMEMPOOL

. common.sh

configure_poolsets 0 1

# XXX: we are using pmemspoil to turn on shutdown state

run_on_node 0 ../pmemspoil  ${NODE_DIR[0]}remote.0.part.1 \
				   pool_hdr.features.incompat=0x0006 \
				   "pool_hdr.f:checksum_gen"

run_on_node 0 ../pmemspoil  ${NODE_DIR[0]}remote.0.part.2 \
				   pool_hdr.features.incompat=0x0006 \
				   "pool_hdr.f:checksum_gen"

run_on_node 1 ../pmemspoil  ${NODE_DIR[1]}pool.part.1 \
				   pool_hdr.shutdown_state.usc=999 \
				   pool_hdr.shutdown_state.dirty=1 \
				   "pool_hdr.shutdown_state.f:checksum_gen" \
				   pool_hdr.features.incompat=0x0006 \
				   "pool_hdr.f:checksum_gen"

run_on_node 1 ../pmemspoil  ${NODE_DIR[1]}pool.part.2 \
				   pool_hdr.features.incompat=0x0006 \
				   "pool_hdr.f:checksum_gen"

expect_normal_exit run_on_node 1 ../pmempool sync ${NODE_DIR[1]}$POOLSET_LOCAL

expect_normal_exit run_on_node 1 ../pmempool sync ${NODE_DIR[1]}$POOLSET_LOCAL

pass
